Setting Parameter Values from Scripts
VectorScript uses the SetRField() function to write values to parameter records. VectorScript also provides two functions, GetCustomObjectInfo() and GetPluginInfo() which return the information needed by SetRField() to write values to parameter records.
Using GetCustomObjectInfo() or GetPluginInfo() with SetRField() is relatively straightforward. When writing a value back to the parameter record of an object instance, first use GetCustomObjectInfo() to obtain information about the object. Once this information has been retrieved, it can be used in conjunction with SetRField() to write the value back to the parameter record. The following example illustrates this technique:
 
In the example, GetCustomObjectInfo() is called to obtain the name of the object and a handle to both the object instance and its associated parameter record. This information is then used with SetRField() to write the value to the parameter record field.
Note that when writing values to the parameter record, the actual name of the field, not the parameter reference, is used. Parameter references should only be used for retrieving data from the parameter record.
The example also points out one additional requirement for using SetRField(). In the example, the value in sp_width is a REAL, but SetRField() requires a STRING argument for the value being assigned to the record field. In this case, it will be necessary to convert the dimension value to a STRING for compatibility with the function call. The parameter record will convert the value back to the appropriate data type when it is stored.
The method for writing values to the parameter records of menu commands and tool items is almost identical to the method used for objects. In the case of menu commands and tool items, the function GetPluginInfo() should be used to obtain the plug-in name and a handle to the parameter record. The example below illustrates how the function is used with a menu command:
 
In the example, GetPluginInfo() is used to obtain the name of the menu command and a handle to the parameter record. This information is used with SetRField() to write values to the parameter record of the menu command.
Parameter records for menu commands and tool items are very useful for storing information between uses of the command or tool item. For example, if a user modifies the default settings of a tool item, this information can be stored and reused on subsequent uses of the tool.
Like objects, records for menu commands and tool items are stored with a VectorWorks file; switching files may cause the default settings for a command or tool item to change.

Using VectorScript Plug-ins : Plug-in Parameter Types : Setting Parameter Values from Scripts

Nemetschek NA
Phone: 410.290.5114
Fax: 410.290.8050